//
//  BIDPayWithCheckboxCell.m
//  HJGJCommunity
//
//  Created by mal on 2017/5/31.
//  Copyright © 2017年 mal. All rights reserved.
//

#import "BIDPayCell.h"

@interface BIDPayCell()
{
}
@end

@implementation BIDPayCell
@synthesize typeImgView;
@synthesize feeNameLabel;
@synthesize amountLabel;
@synthesize radioImgView;
@synthesize expandImgView;
@synthesize isExpand;
@synthesize isFeeChoose;
@synthesize delegate;
@synthesize indexPath;

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.selectionStyle = UITableViewCellSelectionStyleNone;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    if(isExpand)
    {
        [UIView animateWithDuration:0.5f animations:^{
            expandImgView.transform = CGAffineTransformMakeRotation(M_PI);
        }];
    }
    else
    {
        [UIView animateWithDuration:0.5f animations:^{
            expandImgView.transform = CGAffineTransformIdentity;
        }];
    }
}

- (IBAction)btnDownHandler:(id)sender
{
    NSString *imgName = @"";
    if(isFeeChoose)
    {
        isFeeChoose = NO;
        imgName = @"radio_inchoose.png";
    }
    else
    {
        isFeeChoose = YES;
        imgName = @"radio_choose.png";
    }
    [radioImgView setImage:[UIImage imageNamed:imgName]];
    [delegate editSelectStatus:isFeeChoose atIndexPath:indexPath];
}

- (void)prepareWithFeeType:(NSString *)feeType
{
    NSString *imgName = @"";
    if([feeType isEqualToString:@"LODGING_RENT"])
    {
        //房租费
        imgName = @"fee_type_fangzu.png";
    }
    else if([feeType isEqualToString:@"CLEAN_FEE"])
    {
        //卫生费
        imgName = @"fee_type_weisheng.png";
    }
    else if([feeType isEqualToString:@"HEATING_FEE"])
    {
        //暖气费
        imgName = @"fee_type_nuanqi.png";
    }
    else if([feeType isEqualToString:@"PARKING_FEE"])
    {
        //停车费
        imgName = @"fee_type_tingche.png";
    }
    else if([feeType isEqualToString:@"PROPERTY_FEE"])
    {
        //物业费
        imgName = @"fee_type_wuye.png";
    }
    else if([feeType isEqualToString:@"KINDERGARTEN_FEE"])
    {
        //幼儿园费
        imgName = @"fee_type_youeryuan.png";
    }
    else if([feeType isEqualToString:@"WATER_FEE"])
    {
        //水费
        imgName = @"fee_type_water.png";
    }
    else if([feeType isEqualToString:@"ELECTRIC_FEE"])
    {
        //电费
        imgName = @"fee_type_electric.png";
    }
    
    [typeImgView setImage:[UIImage imageNamed:imgName]];
}

- (void)updateFeeSelectState:(BOOL)bFlag
{
    NSString *imgName = @"";
    self.isFeeChoose = bFlag;
    if(!isFeeChoose)
    {
        imgName = @"radio_inchoose.png";
    }
    else
    {
        imgName = @"radio_choose.png";
    }
    [radioImgView setImage:[UIImage imageNamed:imgName]];
}

- (void)isFeeLock:(BOOL)isLock
{
    if(isLock)
    {
        //被锁定
        NSString *strFeeTypeName = feeNameLabel.text;
        NSString *strPostfix = @"(已锁定)";
        NSString *strIntegral = [[NSString alloc] initWithFormat:@"%@%@", strFeeTypeName, strPostfix];
        NSMutableAttributedString *strAttribute = [[NSMutableAttributedString alloc] initWithString:strIntegral];
        [strAttribute addAttribute:NSForegroundColorAttributeName value:[UIColor darkGrayColor] range:NSMakeRange(strFeeTypeName.length, strPostfix.length)];
        feeNameLabel.attributedText = strAttribute;
        _maskBtn.enabled = NO;
        isFeeChoose = NO;
        [radioImgView setImage:[UIImage imageNamed:@"radio_inchoose.png"]];
    }
    else
    {
        _maskBtn.enabled = YES;
        //[radioImgView setImage:[UIImage imageNamed:@"radio_choose.png"]];
    }
}

@end
